from sqlalchemy import Column, Integer, String, Boolean, ForeignKey
from sqlalchemy.orm import relationship

from fastapi_common.db.base_class import Base


class User(Base):
    id = Column(Integer, primary_key=True, autoincrement=True)
    full_name = Column(String(length=255), index=True, comment='用户名')
    email = Column(String(length=255), unique=True, comment='邮箱')
    hashed_password = Column(String(length=255), nullable=False, comment='加密密码')
    phone = Column(String(length=11), unique=True, default='', comment='手机号码唯一')
    is_active = Column(Boolean(), default=True, comment='是否激活')
    role_id = Column(Integer, ForeignKey("role.id"))
    role = relationship("Role", back_populates='users')

